package com.gitee.wsl.mathematics.vector.vec2

import com.gitee.wsl.mathematics.vector.MutableVector
import com.gitee.wsl.mathematics.vector.MutableVectorD
import com.gitee.wsl.mathematics.vector.MutableVectorF
import com.gitee.wsl.mathematics.vector.vec3.MutableVector3
import com.gitee.wsl.mathematics.vector.vec4.MutableVector4

interface MutableVector2<T:Number,V: Vector2<T, V>>: Vector2<T, V>, MutableVector<T, V> {

    //override val vec2: MutableVector2<T, *>
    override val vec3: MutableVector3<T, *>
    override val vec4: MutableVector4<T, *>

    override var x
        get() = proxy[0]
        set(value) {
            proxy[0] = value
        }

    override var y
        get() = proxy[1]
        set(value) {
            proxy[1] = value
        }

    override var length
        get() = sqrt(squaredLength)
        set(value) {
            val newVec = normalized * value
            x = newVec.x
            y = newVec.y
        }

    /*override operator fun plusAssign(other: V) {
        x += other.x
        y += other.y
    }

    override operator fun timesAssign(other: V) {
        x *= other.x
        y *= other.y
    }

    override operator fun divAssign(other: V) {
        x /= other.x
        y /= other.y
    }

    fun subtract(other: V) {
        x -= other.x
        y -= other.y
    }*/

    /*operator fun minusAssign(v: Vector2<T, *>) {
        x -= v.x
        y -= v.y
    }

    operator fun timesAssign(v: Vector2<T, *>) {
        x *= v.x
        y *= v.y
    }

     operator fun divAssign(v: Vector2<T, *>) {
        x /= v.x
        y /= v.y
    }

    operator fun plusAssign(v: Vector2<T, *>) {
        x += v.x
        y += v.y
    }*/

    fun subtract(other:Vector2<T, *>) {
        x -= other.x
        y -= other.y
    }

    fun set(x:Number, y:Number){
        this.x = x+zero
        this.y = y+zero
    }

    //override fun set(other:V) = set(other.x,other.y)

    override fun scale(factor: T) {
        x *= factor
        y *= factor
    }

    fun set(other:Vector2<T, *>) = set(other.x,other.y)

    /*override fun negate() {
        x *= -1f
        y *= -1f
    }*/

}

interface MutableVector2F<V: Vector2<Float, V>> :  MutableVector2<Float, V>, MutableVectorF<V>{

}

interface MutableVector2D<V: Vector2<Double, V>> :  MutableVector2<Double, V>, MutableVectorD<V>{

}